package org.example.controller;

import org.example.po.CommonResult;
import org.example.po.User;
import org.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

//
//@RefreshScope
@RestController
@RequestMapping("/User")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/Login")
    public CommonResult<User> getUserByIdByPass(User user) throws Exception {
        return new CommonResult(200, "success", userService.getUserByIdByPass(user));
    }
//    @GetMapping("/Login")
//    public User getUserByIdByPass(User user) throws Exception {
//        System.out.println(user.getUserId()+"jjj+"+user.getPassword());
//        return  userService.getUserByIdByPass(user);
//    }

    @GetMapping("/UserId")
    public CommonResult<Integer> getUserById(User user) throws Exception {
        User result = userService.getUserById(user.getUserId());
        return new CommonResult(200, "success", result);
    }

    @PostMapping("/UserId")
    public CommonResult<Integer> saveUser(User user) throws Exception {
        int result = userService.saveUser(user);
        return new CommonResult(200, "success", result);
    }
    @GetMapping("/test")
    public String test(){
        return "hello";
    }
}